<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

		<script type="text/javascript">
function t1(){
  			  //form   =   window.document.forms[0];
              //var addr=form.country.value;
             
 
	$.ajax( 
	{
	
		url : "testSelected.do",
		type : 'POST',
		//data : "userName="+addr,
		dataType : 'json',
		success : function(data) {
		
	var sid = document.getElementsByName("country");
	  var op='';
      var val='';
    for(var i=0;i<data.length;i++){  
     var opt = document.createElement('option'); 
      op=data[i];
      val=i;
   	 opt.appendChild(document.createTextNode(op));  
		 opt.setAttribute("value",op); 
		 sid[0].appendChild(opt); 
   }  
			
			
			}
			
	});
			
			}
			
			function t2(){
				var sid1 = document.getElementsByName("country");
				if(sid1[0].value==""){
					return;
				}
						
				
				var s =sid1[0].options[sid1[0].selectedIndex].text;
				//sid1[0].options.length=null;
				 
	$.ajax( 
	{
		url : "countrySelected.do",
		type : 'POST',
		data : "country="+s,
		dataType : 'json',
		success : function(data) {
	  var sidcity = document.getElementsByName("province");
	  var s3 = document.getElementsByName("city");
	  var s4 = document.getElementsByName("area");
	  var s5 = document.getElementsByName("street");
	    sidcity[0].options.length=null;
	    s3[0].options.length=null;
	    s4[0].options.length=null;
	    s5[0].options.length=null;
	     var qingxuanzeoption = document.createElement('option'); 
             qingxuanzetext="请选择";
			 qingxuanzeoption.appendChild(document.createTextNode(qingxuanzetext));  
			 qingxuanzeoption.setAttribute("value",qingxuanzetext); 
		 	 sidcity[0].appendChild(qingxuanzeoption); 
		 var qingxuanzeoption3 = document.createElement('option'); 
             qingxuanzetext3="请选择";
			 qingxuanzeoption3.appendChild(document.createTextNode(qingxuanzetext3));  
			 qingxuanzeoption3.setAttribute("value",qingxuanzetext3); 
		 	 s3[0].appendChild(qingxuanzeoption3); 
		 var qingxuanzeoption4 = document.createElement('option'); 
             qingxuanzetext4="请选择";
			 qingxuanzeoption4.appendChild(document.createTextNode(qingxuanzetext4));  
			 qingxuanzeoption4.setAttribute("value",qingxuanzetext4); 
		 	 s4[0].appendChild(qingxuanzeoption4); 
		var qingxuanzeoption5 = document.createElement('option'); 
             qingxuanzetext5="请选择";
			 qingxuanzeoption5.appendChild(document.createTextNode(qingxuanzetext5));  
			 qingxuanzeoption5.setAttribute("value",qingxuanzetext5); 
		 	 s5[0].appendChild(qingxuanzeoption5); 
		 	 
	
	  var cityop='';
      var cityval='';
      for(var j=0;j<data.length;j++){  
         var cityopt = document.createElement('option'); 
             cityop=data[j];
			 cityopt.appendChild(document.createTextNode(cityop));  
			 cityopt.setAttribute("value",cityop); 
		 	 sidcity[0].appendChild(cityopt); 
   }  
			
			
			}
			
	});
							
							
			}



function t3(){

				var sid2 = document.getElementsByName("province");
					
				var ss = sid2[0].options[sid2[0].selectedIndex].text;
				 
	$.ajax( 
	{
		url : "provinceSelected.do",
		type : 'POST',
		data : "city="+ss,
		dataType : 'json',
		success : function(data) {
	  var cityselect = document.getElementsByName("city");
	   var s4 = document.getElementsByName("area");
	   var s5 = document.getElementsByName("street");
	 	  cityselect[0].options.length=null;
	 	    s4[0].options.length=null;
	    	s5[0].options.length=null;
	  	  	var qingxuanzeoption = document.createElement('option'); 
             qingxuanzetext="请选择";
			 qingxuanzeoption.appendChild(document.createTextNode(qingxuanzetext));  
			 qingxuanzeoption.setAttribute("value",qingxuanzetext); 
		 	 cityselect[0].appendChild(qingxuanzeoption); 
		 	  var qingxuanzeoption4 = document.createElement('option'); 
             qingxuanzetext4="请选择";
			 qingxuanzeoption4.appendChild(document.createTextNode(qingxuanzetext4));  
			 qingxuanzeoption4.setAttribute("value",qingxuanzetext4); 
		 	 s4[0].appendChild(qingxuanzeoption4); 
		var qingxuanzeoption5 = document.createElement('option'); 
             qingxuanzetext5="请选择";
			 qingxuanzeoption5.appendChild(document.createTextNode(qingxuanzetext5));  
			 qingxuanzeoption5.setAttribute("value",qingxuanzetext5); 
		 	 s5[0].appendChild(qingxuanzeoption5); 
		 	 
	  var citytext='';
      var cityvalue='';
      for(var k=0;k<data.length;k++){  
         var cityoption = document.createElement('option'); 
             citytext=data[k];
			 cityoption.appendChild(document.createTextNode(citytext));  
			 cityoption.setAttribute("value",citytext); 
		 	 cityselect[0].appendChild(cityoption); 
   }  
			
			
			}
			
	});
			}
			
			function t4(){
				var sid3 = document.getElementsByName("city");
					
				var sss = sid3[0].options[sid3[0].selectedIndex].text;
				 
	$.ajax( 
	{
		url : "areaSelected.do",
		type : 'POST',
		data : "area="+sss,
		dataType : 'json',
		success : function(data) {
	  var areaselect = document.getElementsByName("area");
	  var s5 = document.getElementsByName("street");
	  	areaselect[0].options.length=null;
	  	s5[0].options.length=null;
	  	var qingxuanzeoption = document.createElement('option'); 
             qingxuanzetext="请选择";
			 qingxuanzeoption.appendChild(document.createTextNode(qingxuanzetext));  
			 qingxuanzeoption.setAttribute("value",qingxuanzetext); 
		 	 areaselect[0].appendChild(qingxuanzeoption); 
	  	var qingxuanzeoption5 = document.createElement('option'); 
             qingxuanzetext5="请选择";
			 qingxuanzeoption5.appendChild(document.createTextNode(qingxuanzetext5));  
			 qingxuanzeoption5.setAttribute("value",qingxuanzetext5); 
		 	 s5[0].appendChild(qingxuanzeoption5); 
		 	 
	  	
	  var areatext='';
      var areavalue='';
      for(var l=0;l<data.length;l++){  
         var areaoption = document.createElement('option'); 
             areatext=data[l];
			 areaoption.appendChild(document.createTextNode(areatext));  
			 areaoption.setAttribute("value",areatext); 
		 	 areaselect[0].appendChild(areaoption); 
   }  
			
			
			}
			
	});
			}
			
					function t6(){
				var sid3 = document.getElementsByName("area");
					
				var sss = sid3[0].options[sid3[0].selectedIndex].text;
				 
	$.ajax( 
	{
		url : "streetSelected.do",
		type : 'POST',
		data : "street="+sss,
		dataType : 'json',
		success : function(data) {
	  var streetselect = document.getElementsByName("street");
	  	streetselect[0].options.length=null;
	  	
	  	var qingxuanzeoption = document.createElement('option'); 
             qingxuanzetext="请选择";
			 qingxuanzeoption.appendChild(document.createTextNode(qingxuanzetext));  
			 qingxuanzeoption.setAttribute("value",qingxuanzetext); 
		 	 streetselect[0].appendChild(qingxuanzeoption); 
	  	
	  var streettext='';
      var streetvalue='';
      for(var l=0;l<data.length;l++){  
         var streetoption = document.createElement('option'); 
             streettext=data[l];
			 streetoption.appendChild(document.createTextNode(streettext));  
			 streetoption.setAttribute("value",streettext); 
		 	 streetselect[0].appendChild(streetoption); 
   }  
			
			
			}
			
	});
			}
			
		</script>

			country : <html:select property="country" onchange="t2()">
				<html:option value="">请选择</html:option>
			</html:select>
			<html:errors property="country" />
			
			province : <html:select property="province" onchange="t3()">
				<html:option value="">请选择</html:option>
			</html:select>
			<html:errors property="province" />		
			
			city : <html:select property="city" onchange="t4()">
				<html:option value="">请选择</html:option>
			</html:select>
			<html:errors property="city" />	
			
			
			area/port : <html:select property="area" onchange="t6()">
				<html:option value="">请选择</html:option>
			</html:select>
			<html:errors property="area" />
			<br />
			
			street/portnum : <html:select property="street">
				<html:option value="">请选择</html:option>
			</html:select>
			<html:errors property="street" />
			
			
			detail: <html:text property="startAddress6" value="address level6" size="45"/>
		


